package moduloIndexacion.analizador;

import java.io.File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import entidades.Extension;

import jxl.Cell;
import jxl.CellType;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;


public class AnalizadorExcel_xls extends TemplateAnalizador{
	
	public AnalizadorExcel_xls(){
		super.extension = new Extension ("xls","Microsoft Excel Versiones Pre 2007");
	}
	
	@Override
	protected String obtenerTexto() {
		String rutaAcceso = documento.getUbicacion()+documento.getNombre();
		String textoExcel="";
									
		try {
			File inputWorkbook = new File(rutaAcceso);
			Workbook w;
			w = Workbook.getWorkbook(inputWorkbook);
									
			Sheet sheet = w.getSheet(0);
			
			textoExcel = w.getSheets().toString();
			
			for (int j = 0; j < sheet.getColumns(); j++) 
			{
				for (int i = 0; i < sheet.getRows(); i++) 
				{					
					Cell cell = sheet.getCell(j, i);
					textoExcel += cell.getContents();									
				}
			}						
		} 	
		catch (Exception e)
		{
			
		}
							
		return textoExcel;
	}
}
